package ltd.goods.cloud.newbee.controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Auther: tangyushan
 * @Date: 2024/5/24 - 05 - 24 - 17:33
 * @Description: ltd.newbee.cloud.api
 * @version: 1.0
 */
@RestController
public class NewBeeCloudGoodsAPI {

    @Value("${server.port}")
    private String applicationServerPort;

    @GetMapping("/goods")
    public String goodsDetail(@RequestParam("goodsId") int goodsId){
        //根据id查询商品并返回调用端
        if(goodsId < 1 || goodsId > 100000) {
            return "查询商品为空，当前服务的端口号为" + applicationServerPort;
        }
        String goodsName = "商品" + goodsId;
        //返回信息给调用端
        return goodsName + ",当前服务的端口号为：" + applicationServerPort;
    }

    @GetMapping("/goods/page/{pageNum}")
    public String goodList(@PathVariable("pageNum") int pageNum) {
        //返回信息给调用端
        return "请求goodsList，当前服务的端口号为" + applicationServerPort;
    }
}
